﻿@{
    ViewBag.Title = "翻相册";
}
<div class="bread"><a href="/index">首页</a> &gt; 翻相册</div>
<div class="kindOfGallery">
    <ul>
        <li class="selected"><a href="javascript:void(0)" onclick="Op.call(this,1)">楼盘相册（<span id="pnum">0</span>）</a></li>
        <li><a href="javascript:void(0)" onclick="Op.call(this,2)">景区相册（<span id="lnum">0</span>）</a></li>
    </ul>
</div>
<div class="deepSearch">
    <select  onchange="javascript:GetList(1)" id="selP">
	    <option selected="selected" value="0">按项目名称查找</option>
	   @foreach (var item in ViewBag.PList)
        {
            <option value="@item.XMID">@item.XMMC</option>
        }
    </select>
    <select onchange="javascript:GetList(2)" id="selL" style="display:none">
	    <option selected="selected" value="0">按景区名称查找</option>
	    <@foreach (var item in ViewBag.LList)
        {
            <option value="@item.JQID">@item.JQMC</option>
        }
    </select>
</div>
<div class="galleryPage">
    <ul id="tablist">    
    </ul>
</div>
<!--page-->
<hr />
<script type="text/javascript">
    $(function () {
        GetList(1);
    });

    //tab控制
    function Op(type) {
        $(this).parent().parent().children().removeClass("selected");
        $(this).parent().attr('class', "selected");
        if (type == 1) {
            $("#selP").show();
            $("#selL").hide();
        }
        else {
            $("#selL").show();
            $("#selP").hide();
        }
        GetList(type);
    }

    //get list data
    function GetList(type) {
        $.ajax({
            url: "/xiangce/get_xiangce_list",
            type: "POST",
            dataType: "json",
            data: {
                pid: $("#selP").val(),
                lid:$("#selL").val(),
                type : type
            },
            timeout: 30000,
            success: function (data) {
                if (data.list.length > 0) {
                    if (type == 1) {
                        $("#pnum").html(data.count);
                    }
                    else {
                        $("#lnum").html(data.count);
                    }
                    createHTML(data.list, type);
                }
                else {
                    $("#tablist").html("<li style='color:red;'>没有数据！</li>");
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                dlg.Msg.Err(errorThrown);
            }
        });
    }

    // page call back function
    function pageselectCallback(page_index) {
        GetList(page_index);
    }

    //create html
    function createHTML(data, type) {
        var _html = "";
        $(data).each(function (i, item) {
            var _li = '<li>';
            if (type == 1) {
                _li += '<a href="/xiangce/photos/' + item.XMID + '">';
            }
            else {
                _li += '<a href="/xiangce/landspace_photo_list?id=' + item.XMID + '">';
            }
            _li += '<img src="/uploadfiles/others/' + item.XMLBT + '" width="223" height="158">\
            </a><span>' + item.XMMC + '('+ item.Total +')</span></li>';
            _html += _li;
        });
        $("#tablist").html(_html);
    }
</script>